package com.ute.chinesechess;

public class Tinh extends QuanCo {
	public boolean KiemTra(int i, int j) {
		/*
		 * Kiem tra lai con sai
		 */

		boolean turn = false;
		if (Phe == 0) {
			if (i >= 0 && i <= 4 && j >= 0 && j <= 8) {
				if (i == Hang + 2 && j == Cot + 2) {
					if (BanCo.board[Hang + 1][Cot + 1].Trong == true)
						turn = true;
				} else if (i == Hang - 2 && j == Cot + 2) {
					if (BanCo.board[Hang - 1][Cot + 1].Trong == true)
						turn = true;
				} else if (i == Hang + 2 && j == Cot - 2) {
					if (BanCo.board[Hang + 1][Cot - 1].Trong == true)
						turn = true;
				} else if (i == Hang - 2 && j == Cot - 2) {
					if (BanCo.board[Hang - 1][Cot - 1].Trong == true)
						turn = true;
				} else
					return false;
				if (BanCo.board[i][j].Trong == false) {
					if (BanCo.board[i][j].Phe != this.Phe)
						turn = true;
					else
						turn = false;
				} else
					turn = true;
			}
		} else {
			if (i >= 5 && i <= 9 && j >= 0 && j <= 8) {
				if (i == Hang + 2 && j == Cot + 2) {
					if (BanCo.board[Hang + 1][Cot + 1].Trong == true)
						turn = true;
				} else if (i == Hang - 2 && j == Cot + 2) {
					if (BanCo.board[Hang - 1][Cot + 1].Trong == true)
						turn = true;
				} else if (i == Hang + 2 && j == Cot - 2) {
					if (BanCo.board[Hang + 1][Cot - 1].Trong == true)
						turn = true;
				} else if (i == Hang - 2 && j == Cot - 2) {
					if (BanCo.board[Hang - 1][Cot - 1].Trong == true)
						turn = true;
				} else
					return false;
				if (BanCo.board[i][j].Trong == false) {
					if (BanCo.board[i][j].Phe != this.Phe)
						turn = true;
					else
						turn = false;
				} else
					turn = true;
			}
		}
		return turn;
	}
}
